const Store = require('electron-store') // electron自带的存储
const store = new Store();

let userId = null;
const setUserId = (_userId) => {
    userId = _userId;
}

const getUserId = () => {
    return userId;
}

const setData = (key, value) => {
    store.set(key, value);
};

const getData = (key) => {
    return store.get(key);
};

const setUserData = (key, value) => {
    store.set(`user_${userId}_${key}`, value);
};

const getUserData = (key) => {
    return store.get(`user_${userId}_${key}`);
};

const deleteUserData = (key) => {
    store.delete(`user_${userId}_${key}`);
};

export default {
    setData,
    getData,
    setUserId,
    getUserId,
    setUserData,
    getUserData,
    deleteUserData
}